var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function n() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((n.prototype = i.prototype), new n()));
      };
    })(),
  DPPawnShopView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.pawnDict = []),
        (t.onLoadPurauseItemFn = {
          caller: t,
          code: 2077,
          method: function (e) {
            if (0 == e.code) {
              t.itemArr = e.list;
              for (var i, n = [], o = e.list, a = 0; a < o.length; a++)
                (i = {
                  lbl_pawn_name: { text: o[a].thing_name },
                  btn_headIcon: {
                    skin: Utils.getUserHeadSkin(o[a].roleType, o[a].sex),
                  },
                  lbl_pawn_coin: { text: o[a].gold + " 金" },
                  thing_type: o[a].thing_type,
                  thing_id: o[a].thing_id,
                  role_id: o[a].role_id,
                }),
                  n.push(i);
              t.list_pawnShop.array = n;
            }
          },
        }),
        (t.onLoadGouMaiRenFn = {
          caller: t,
          code: 2081,
          method: function (e) {
            0 == e.code
              ? ((t.text_goumairenID.visible = !1),
                (t.lbl_buy_roleID.visible = !0),
                (t.btn_zhidinggoumairen.visible = !1),
                (t.lbl_buy_roleID.text =
                  e.data + "( " + t.text_goumairenID.text + " )"),
                (t.isToPersoon = !0),
                t.onTextBlurFn())
              : ToastView.toastView(e.msg);
          },
        }),
        (t.onLoadCancleSaleFn = {
          caller: t,
          code: 2085,
          method: function (e) {
            ToastView.toastView(e.msg),
              (t.btn_quedingjishou.label = "确定寄售"),
              (t.text_goumairenID.text = ""),
              (t.text_jishou_price.text = ""),
              WebSocketService.send({ c: 2075, d: null });
          },
        }),
        (t.onLoadJiShouWupinFn = {
          caller: t,
          code: 2076,
          method: function (e) {
            0 == e.code
              ? WebSocketService.send({ c: 2075, d: null })
              : ToastView.toastView(e.msg);
          },
        }),
        (t.onDangPuHomeDataFn = {
          caller: t,
          code: 2075,
          method: function (e) {
            0 == e.code
              ? ((t.pawnDict = e.data),
                (t.lbl_buy_roleID.visible = !1),
                (t.lbl_money_price.visible = !1),
                (t.text_jishou_price.visible = !0),
                (t.text_goumairenID.visible = !0),
                (t.btn_zhidinggoumairen.visible = !0),
                (t.lbl_pawn_tipone.visible = !0),
                (t.lbl_pawn_tiptwo.visible = !0),
                (t.shop_id = e.data.thing_id),
                0 == e.data.state
                  ? e.data.thing_name.length
                    ? ((t.btn_xuanzejishouwupin.label = e.data.thing_name),
                      (t.btn_chexiaojishou.visible = !0))
                    : ((t.btn_chexiaojishou.visible = !1),
                      (t.btn_xuanzejishouwupin.label = "选择寄售物品"))
                  : 1 == e.data.state
                  ? ((t.lbl_buy_roleID.visible = !0),
                    (t.lbl_money_price.visible = !0),
                    (t.text_jishou_price.visible = !1),
                    (t.text_goumairenID.visible = !1),
                    (t.btn_quedingjishou.label = "撤销寄售"),
                    (t.btn_zhidinggoumairen.visible = !1),
                    (t.btn_chexiaojishou.visible = !0),
                    (t.lbl_pawn_tipone.visible = !1),
                    (t.lbl_pawn_tiptwo.visible = !1),
                    (t.btn_xuanzejishouwupin.label = e.data.thing_name),
                    (t.lbl_money_price.text = e.data.gold),
                    (t.lbl_buy_roleID.text = e.data.buy_roleid))
                  : e.data.state)
              : ((t.tab_pawnChange.selectedIndex = 0),
                (t.image_goumai.visible = !0),
                (t.image_jishou.visible = !1),
                (t.btn_pawn_history.label = "购买记录"),
                NormalDialog.showNormalDialog(e.msg, t, t.onNoCanJiShouAction));
          },
        }),
        t.btn_shopDangPu_back.on(Laya.Event.CLICK, t, t.onDangpuBackPreFn),
        t.tab_pawnChange.on(Laya.Event.CLICK, t, t.onTabPawnExchargeFn),
        t.btn_pawn_history.on(Laya.Event.CLICK, t, t.onPawnHistoryFn),
        t.btn_sale_rule.on(Laya.Event.CLICK, t, t.onSaleRuleClick),
        WebSocketService.addListener(t.onLoadPurauseItemFn),
        t.tab_pawnItem.on(Laya.Event.CLICK, t, t.onTabPawnItemFn),
        t.btn_zhidinggoumairen.on(Laya.Event.CLICK, t, t.onZhiDingGouMaiRenFn),
        t.btn_quedingjishou.on(Laya.Event.CLICK, t, t.onQueDingJiShouWupiFn),
        t.btn_xuanzejishouwupin.on(Laya.Event.CLICK, t, t.onXuanZeSaleWuPinFn),
        t.btn_chexiaojishou.on(Laya.Event.CLICK, t, t.onCheXiaoJiShouFn),
        t.btn_sale_yixiangren.on(Laya.Event.CLICK, t, t.onSaleYiXiangRenClick),
        WebSocketService.addListener(t.onDangPuHomeDataFn, !0),
        WebSocketService.addListener(t.onLoadJiShouWupinFn, !0),
        WebSocketService.addListener(t.onLoadGouMaiRenFn),
        WebSocketService.addListener({
          caller: t,
          code: 2098,
          method: t.onLoadFuJiangDetailFn,
        }),
        WebSocketService.addListener(t.onLoadCancleSaleFn),
        WebSocketService.addListener({
          caller: t,
          code: 2097,
          method: t.onLoadBuyPawnWupinFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5315,
          method: t.onLoadRoleSalesData,
        }),
        (t.list_pawnShop.vScrollBarSkin = ""),
        (t.list_pawnShop.selectEnable = !0),
        t.list_pawnShop.on(Laya.Event.CLICK, t, t.onPawnShopFuntion),
        (t.list_pawnShop.renderHandler = new Laya.Handler(
          t,
          t.updatePawnShopItem
        )),
        t.text_jishou_price.on(Laya.Event.FOCUS, t, t.onTextBlurFn),
        t.text_jishou_price.on(Laya.Event.BLUR, t, t.onTextBlurFn),
        t.text_goumairenID.on(Laya.Event.FOCUS, t, t.onTextBlurFn),
        t.text_goumairenID.on(Laya.Event.BLUR, t, t.onTextBlurFn),
        (t.list_juesejiaoyi.vScrollBarSkin = ""),
        (t.list_juesejiaoyi.selectEnable = !0),
        t.list_juesejiaoyi.on(Laya.Event.CLICK, t, t.onListJueSeJiaoYiFuntion),
        t
      );
    }
    return (
      __extends(t, e),
      (t.openView = function () {
        return (
          null == this.pawnshopVC && (this.pawnshopVC = new t()),
          (this.pawnshopVC.curClsState = !0),
          (this.pawnshopVC.image_goumai.visible = !0),
          (this.pawnshopVC.image_jishou.visible = !1),
          (this.pawnshopVC.image_juesejiaoyi.visible = !1),
          (this.pawnshopVC.list_pawnShop.selectedIndex = -1),
          (this.pawnshopVC.tab_pawnItem.selectedIndex = 0),
          (this.pawnshopVC.tab_pawnChange.selectedIndex = 0),
          (this.pawnshopVC.itemArr = []),
          this.pawnshopVC.onTextBlurFn(),
          (this.pawnshopVC.isToPersoon = !1),
          (this.pawnshopVC.btn_quedingjishou.disabled = !1),
          WebSocketService.send({ c: 2077, d: { type: 0, pageNum: 0 } }),
          this.pawnshopVC
        );
      }),
      (t.prototype.onTabPawnItemFn = function (e) {
        "item0" == e.target.name
          ? (WebSocketService.send({ c: 2077, d: { type: 0, pageNum: 0 } }),
            (this.shop_type = "0"))
          : "item1" == e.target.name
          ? (WebSocketService.send({ c: 2077, d: { type: 1, pageNum: 0 } }),
            (this.shop_type = "1"))
          : "item2" == e.target.name
          ? (WebSocketService.send({ c: 2077, d: { type: 2, pageNum: 0 } }),
            (this.shop_type = "2"))
          : "item3" == e.target.name &&
            (WebSocketService.send({ c: 2077, d: { type: 3, pageNum: 0 } }),
            (this.shop_type = "3"));
      }),
      (t.prototype.onZhiDingGouMaiRenFn = function () {
        var e = parseInt(this.text_goumairenID.text);
        (isNaN(e) || e > 0) &&
          WebSocketService.send({ c: 2081, d: { roleId: e } });
      }),
      (t.prototype.onQueDingJiShouWupiFn = function (e) {
        if ("撤销寄售" != e.target.label) {
          var t = parseInt(this.text_jishou_price.text);
          t <= 0 || isNaN(t)
            ? ToastView.toastView("请输入寄售价格")
            : WebSocketService.send({ c: 2076, d: { act: 1, gold: t } });
        } else WebSocketService.send({ c: 2085, d: null });
      }),
      (t.prototype.onTabPawnExchargeFn = function (e) {
        console.log(e.target.name),
          "item0" == e.target.name
            ? ((this.image_goumai.visible = !0),
              (this.image_jishou.visible = !1),
              (this.image_juesejiaoyi.visible = !1),
              (this.btn_pawn_history.label = "购买记录"),
              WebSocketService.send({ c: 2077, d: { type: 0, pageNum: 0 } }),
              (this.pawnDict = []))
            : "item1" == e.target.name
            ? ((this.image_goumai.visible = !1),
              (this.image_jishou.visible = !0),
              (this.image_juesejiaoyi.visible = !1),
              (this.btn_chexiaojishou.visible = !1),
              (this.btn_pawn_history.label = "出售记录"),
              (this.pawnDict = []),
              WebSocketService.send({ c: 2075, d: null }))
            : "item2" == e.target.name &&
              ((this.image_goumai.visible = !1),
              (this.image_jishou.visible = !1),
              (this.image_juesejiaoyi.visible = !0),
              (this.btn_sale_yixiangren.visible = !1),
              WebSocketService.send({ c: 5315, d: { roleId: Global.roleId } }));
      }),
      (t.prototype.onPawnHistoryFn = function () {
        var e = "1" + this.tab_pawnChange.selectedIndex;
        AXMarketRechargesView.showMarketChargesView(e);
      }),
      (t.prototype.onXuanZeSaleWuPinFn = function (e) {
        if ("选择寄售物品" == e.target.label) DPChooseGoodsView.openView();
        else if (0 != e.target.label.length) {
          this.pawnDict.thing_name,
            this.shop_id,
            this.pawnDict.thing_type,
            this.pawnDict.gold,
            this.tab_pawnItem.selectedIndex;
          WebSocketService.send({ c: 2098, d: { id: this.shop_id } });
        }
      }),
      (t.prototype.onCheXiaoJiShouFn = function () {
        WebSocketService.send({ c: 2076, d: { act: 3, gold: 0 } });
      }),
      (t.prototype.onPawnShopFuntion = function (e) {
        if ("" != e.target.name) {
          var t = this.list_pawnShop.selectedItem;
          if ("btn_headIcon" != e.target.name)
            if (2 == t.thing_type || 5 == t.thing_type) {
              var i = this.itemArr[this.list_pawnShop.selectedIndex];
              if (void 0 == i) return;
              var n = {
                pawnId: i.role_id,
                name: i.thing_name,
                thing_id: i.thing_id,
                thing_type: i.thing_type,
                count: 1,
                money: i.gold,
              };
              DPItemDetailPageView.showItemDetailPageView(n, "DPPawnShopView");
            } else
              3 == t.thing_type &&
                WebSocketService.send({ c: 2098, d: { id: t.thing_id } });
          else FriendsDetailDialog.showFriendDialog(t.role_id, !0);
        }
      }),
      (t.prototype.onLoadFuJiangDetailFn = function (e) {
        if (0 == e.code && this.curClsState) {
          var t = e.data;
          if (this.list_pawnShop.selectedItem) {
            var i = this.itemArr[this.list_pawnShop.selectedIndex],
              n = {
                pawnId: i.role_id,
                money: i.gold,
                data: t,
                type: this.tab_pawnItem.selectedIndex,
              };
            DPHeroDetailDialog.showHeroDetailDialog(n);
          } else {
            n = { pawnId: "", money: "0", data: t, type: "-1" };
            DPHeroDetailDialog.showHeroDetailDialog(n);
          }
        }
      }),
      (t.prototype.updatePawnShopItem = function (e, t) {}),
      (t.prototype.onNoCanJiShouAction = function () {}),
      (t.prototype.onLoadBuyPawnWupinFn = function (e) {
        0 == e.code
          ? (ToastView.toastView("成功购买"),
            WebSocketService.send({
              c: 2077,
              d: { type: this.tab_pawnItem.selectedIndex, pageNum: 0 },
            }))
          : ToastView.toastView(e.msg);
      }),
      (t.prototype.onLoadRoleSalesData = function (e) {
        if (0 == e.code) {
          var t = e.data;
          this.roleArr = [];
          for (var i = void 0, n = !1, o = 0; o < t.length; o++) {
            var a = t[o];
            a.roleId == Global.roleId && (n = !0),
              (i = {
                btn_headIcon: {
                  skin: Utils.getUserHeadSkin(a.roleType, a.sex),
                },
                item_role_name: { text: a.roleName },
                item_role_info: { text: a.lvl + "级" },
                item_role_favor: { text: a.purposeCount + "人\n想要" },
                roleName: a.roleName,
                roleId: a.roleId,
                userId: a.userId,
                purpose: a.purpose,
              }),
              this.roleArr.push(i);
          }
          (this.list_juesejiaoyi.array = this.roleArr),
            n && (this.btn_sale_yixiangren.visible = !0);
        }
      }),
      (t.prototype.onListJueSeJiaoYiFuntion = function (e) {
        if ("" != e.target.name) {
          var t = this.list_juesejiaoyi.selectedItem;
          DPPawnSaleDialog.showPawnSaleView(t);
        }
      }),
      (t.prototype.onTextBlurFn = function () {
        if (this.text_jishou_price.text.length > 0) {
          if (this.text_goumairenID.text.length > 0 && 0 == this.isToPersoon)
            return void (this.btn_quedingjishou.disabled = !0);
          this.btn_quedingjishou.disabled = !1;
        } else
          1 == this.text_jishou_price.visible &&
            (this.btn_quedingjishou.disabled = !0);
      }),
      (t.prototype.onSaleYiXiangRenClick = function (e) {
        var t = this.list_juesejiaoyi.selectedItem;
        CommonUIDialog.showCommonUIDialog(t, "accountRole");
      }),
      (t.prototype.onSaleRuleClick = function () {
        var e = CaslnoRulesView.showCaslRuleView("sale_rule");
        (e.y = 35), Laya.stage.addChild(e);
      }),
      (t.prototype.onDangpuBackPreFn = function () {
        (this.curClsState = !1), this.removeSelf();
      }),
      t
    );
  })(ui.MarketController.DPPawnShopViewUI);
